package com.sedshop.shop.library.volley;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by Administrator on 2015/5/19.
 */
public class MD5Utils {
    public static String getMD5Str(String s){
        StringBuffer sb = new StringBuffer();
        try {
            MessageDigest md5 = MessageDigest.getInstance("md5");
            byte[] digest_byte = md5.digest(s.getBytes());
            for (byte b : digest_byte) {
                int number = b & 0xff;// b & 0x3f 加盐算法
                String str = Integer.toHexString(number);
                if (str.length() == 1) {
                    sb.append("0");
                }
                sb.append(str);
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}
